package com.example.userconsumer.controller;

import cn.example.entity.User;
import com.example.userconsumer.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName UserController
 * @Description TODO
 * @Author yaozhaobao
 * @Date 2020/7/13 12:49
 * @Version 1.0
 **/
@RestController
public class UserController {


    @Autowired
    UserService userService;

    @RequestMapping(value = "login")
    public String login(@RequestParam String name,@RequestParam String pwd){

        if (userService.login(name,pwd)){
            return "登录成功";
        }else{
            return "用户名密码有误";
        }
    }

    @RequestMapping(value = "login2")
    public String login2(@RequestParam String name,@RequestParam String pwd){

        User user =new User();
        user.setName(name);
        user.setPassword(pwd);
        if (userService.login2(user)){
            return "登录成功";
        }else{
            return "用户名密码有误";
        }
    }

    @RequestMapping(value = "login3")
    public String login3(@RequestParam Integer count){
        for (int i=0;i<count;i++){
            userService.login3(i);
        }
        return "执行成功";

    }
}
